package gdr.player;
/**
 * Gestisce un insieme di statistiche
 * @author Giorgio Vitale
 *
 */
@SuppressWarnings("serial")
public class Statistiche implements java.io.Serializable{

	public static final int HP = 0;
	public static final int MP = 1;
	public static final int ATK = 2;
	public static final int DEF = 3;
	public static final int MAG = 4;
	public static final int RES = 5;
	public static final int SPD = 6;
	public static final int HIT = 7;
	
	public static final int STAT_NUM =8;
	
	protected long[] stats;

	public Statistiche(){
		stats = new long[STAT_NUM];
	}
	public long[] getStats() {
		return stats;
	}

	public void setStats(long[] stats) {
		this.stats = stats;
	}
	/**
	 * restituisce una particolare statistica
	 * @param stat
	 * @return
	 */
	public long getStat(int stat){
		if (stat<0 || stat>STAT_NUM) throw new IllegalArgumentException();
		return stats[stat];
	}
	/**
	 * imposta una particolare statistica
	 * @param stat
	 * @param value
	 */
	public void setStat(int stat, long value){
		if (stat<0 || stat>STAT_NUM) throw new IllegalArgumentException();
		stats[stat] = value;
	}
	/**
	 * Dato l'identificativo della statistica, ne restituisce il nome.
	 * @param stat
	 * @return
	 */
	public String getStatDescriptor(int stat){
		if (stat<0 || stat>STAT_NUM) throw new IllegalArgumentException();
		switch (stat)
		{	case HP: return "HP";
			case MP: return "MP";
			case ATK: return "ATK";
			case DEF: return "DEF";
			case MAG: return "MAG";
			case RES: return "RES";
			default: return "";
		}
	}
	
	public String toString(){
		String s = "";
		for (int i=0; i<STAT_NUM; i++)
			s+=getStatDescriptor(i)+":"+stats[i]+";";
		return "["+s.substring(0, s.length()-1)+"]";
	}
}
